package com.ruoyi.web.controller.squad;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.squadweb.domain.SquadjsAllBanInfo;
import com.ruoyi.squadweb.service.ISquadjsAllBanInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广播消息Controller
 *
 * @author ruoyi
 * @date 2024-03-04
 */
@RestController
@RequestMapping("/system/info")
public class SquadjsAllBanInfoController extends BaseController
{
    @Autowired
    private ISquadjsAllBanInfoService squadjsAllBanInfoService;

    /**
     * 查询广播消息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(SquadjsAllBanInfo squadjsAllBanInfo)
    {
//        startPage();
        List<SquadjsAllBanInfo> list = squadjsAllBanInfoService.selectSquadjsAllBanInfoList(squadjsAllBanInfo);
        return getDataTable(list);
    }

    /**
     * 导出广播消息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "广播消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SquadjsAllBanInfo squadjsAllBanInfo)
    {
        List<SquadjsAllBanInfo> list = squadjsAllBanInfoService.selectSquadjsAllBanInfoList(squadjsAllBanInfo);
        ExcelUtil<SquadjsAllBanInfo> util = new ExcelUtil<SquadjsAllBanInfo>(SquadjsAllBanInfo.class);
        util.exportExcel(response, list, "广播消息数据");
    }

    /**
     * 获取广播消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{steamid}")
    public AjaxResult getInfo(@PathVariable("steamid") Long steamid)
    {
        return success(squadjsAllBanInfoService.selectSquadjsAllBanInfoBySteamid(steamid));
    }

    /**
     * 新增广播消息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "广播消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SquadjsAllBanInfo squadjsAllBanInfo)
    {
        return toAjax(squadjsAllBanInfoService.insertSquadjsAllBanInfo(squadjsAllBanInfo));
    }

    /**
     * 修改广播消息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "广播消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SquadjsAllBanInfo squadjsAllBanInfo)
    {
        return toAjax(squadjsAllBanInfoService.updateSquadjsAllBanInfo(squadjsAllBanInfo));
    }

    /**
     * 删除广播消息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "广播消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{steamids}")
    public AjaxResult remove(@PathVariable Long[] steamids)
    {
        return toAjax(squadjsAllBanInfoService.deleteSquadjsAllBanInfoBySteamids(steamids));
    }
}
